Fix reference counting issues in gdb.cc and waypt.cc exposed by valgrind.Z
authorrobertlipe <robertlipe@gmail.com>
Sun, 24 Mar 2013 05:10:32 +0000 (05:10 +0000)
committerrobertlipe <robertlipe@gmail.com>
Sun, 24 Mar 2013 05:10:32 +0000 (05:10 +0000)
gpsbabel/gdb.cc
gpsbabel/waypt.cc

index 09038461d943552e8029e20eacdef8720aed4436..5efde6f9635843471907db4ac29722e7f9ea43a4 100644 (file)
@@ -1337,15 +1337,15 @@ write_waypoint(
 
   /* VERSION DEPENDENT CODE */
   if (gdb_ver <= GDB_VER_2) {
-    char* descr;
+    QString descr;
 
     FWRITE(zbuf, 3);
     FWRITE(zbuf, 4);
     descr = (wpt_class < gt_waypt_class_map_point) ?
-            wpt->url.toUtf8().data() : wpt->description;
+            wpt->url : wpt->description;
     if ((descr != NULL) && (wpt_class >= gt_waypt_class_map_point) && \
-        (strcmp(descr, wpt->shortname) == 0)) {
-      descr = NULL;
+        descr.compare(wpt->shortname) == 0) {
+      descr.clear();
     }
     FWRITE_CSTR(descr);
   } else { /* if (gdb_ver > GDB_VER_3) */
index 2f5b89dc5581dc4a13039dd05e8755ec759c4bd8..3cf5661c695a1f82a13010e29e3e7a03f9ec7781 100644 (file)
@@ -394,6 +394,9 @@ waypt_free(waypoint *wpt)
   if (wpt->notes) {
     xfree(wpt->notes);
   }
+
+#if 0
+  // these are now ref counted...
   if (wpt->url_next) {
     url_link *url_next;
 
@@ -404,6 +407,7 @@ waypt_free(waypoint *wpt)
       xfree(tonuke);
     }
   }
+#endif
 
   if (wpt->gc_data != &empty_gc_data) {
     geocache_data *gc_data = (geocache_data *)wpt->gc_data;